package com.example.arguslogexample.controller;

import com.example.arguslogexample.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author chenenwei
 */

@RequestMapping("/api")
@RestController
public class ApiController {

    @Autowired
    private UserService userService;

    @GetMapping("/noParam")
    public String hello() {
        return "hello argus";
    }

    @GetMapping("/queryParam")
    public String queryParam(String name, Integer age) {
        return "name: " + name + ", age: " + age;
    }

    @PostMapping("/bodyParam")
    public Object bodyParam(Map<String, Object> param) {
        return param;
    }

    @GetMapping("/tree")
    public Object tree(Long id) {
        return userService.getUserById(id);
    }
}
